package com.boot.controller;

import com.boot.dao.UserDao;
import com.boot.modal.add.UserAdd;
import com.boot.myannotation.MyLog;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Optional;

/**
 * @author MShaoJie
 * @create 2021/8/25 14:08
 **/
@RequestMapping("/user")
@RestController
public class UserController {

    @RequestMapping(value = "/query", method = RequestMethod.GET)
    @MyLog(operateType = "query", operateExplain = "用户list查询")
    public ResponseEntity<UserDao> query(@Valid UserDao userDao) {
        UserDao user = new UserDao(1L, "msj");
        return ResponseEntity.of(Optional.ofNullable(user));
    }

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @MyLog(operateType = "add", operateExplain = "添加用户操作")
    public ResponseEntity<UserDao> add(@Valid @RequestBody UserAdd user) {
        return ResponseEntity.ok(null);
    }

}
